package xyz.zdsoft.common_module.controller;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import xyz.zdsoft.common.utils.Result;
import xyz.zdsoft.common_module.dto.ChangePwd;
import xyz.zdsoft.common_module.service.CommonService;

import javax.servlet.http.HttpServletRequest;
import java.util.Map;

@Api(value = "公共模块", tags = "下拉框等公共接口")
@RestController
@RequestMapping("/api/common_module/a_t_s")
public class CommonController {


    private final CommonService commonService;

    public CommonController(CommonService commonService) {
        this.commonService = commonService;
    }

    @ApiOperation(value = "课程下拉框", notes = "课程下拉框")
    @PostMapping("/getCourse")
    public Result getCourse(HttpServletRequest request){
        return commonService.getCourse(request);
    }

    @ApiOperation(value = "老师下拉框", notes = "老师下拉框")
    @PostMapping("/getTeacher")
    public Result getTeacher(String teacherName){
        return commonService.getTeacher(teacherName);
    }

    @ApiOperation(value = "小组下拉框", notes = "小组下拉框")
    @PostMapping("/getTeam")
    public Result getTeam(){
        return commonService.getTeam();
    }

    @ApiOperation(value = "院系下拉框", notes = "院系下拉框")
    @PostMapping("/getCollege")
    public Result getCollege(){
        return commonService.getCollege();
    }

    @ApiOperation(value = "专业下拉框", notes = "专业下拉框")
    @PostMapping("/getMajor")
    public Result getMajor(Integer collegeId){
        return commonService.getMajor(collegeId);
    }

    @ApiOperation(value = "年级下拉框", notes = "年级下拉框")
    @PostMapping("/getGrade")
    public Result getGrade(){
        return commonService.getGrade();
    }

    @ApiOperation(value = "班级下拉框", notes = "班级下拉框")
    @PostMapping("/getClassInfo")
    public Result getClassInfo(){
        return commonService.getClassInfo();
    }

    @ApiOperation(value = "修改密码", notes = "修改密码")
    @PostMapping("/updatePassword")
    public Result updatePassword(HttpServletRequest request, @RequestBody ChangePwd cp){
        return commonService.updatePassword(request,cp);
    }
}
